package com.test.source_learn.step1;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.logging.LoggingHandler;


public class Server {
    public static void main(String[] args) {
        new ServerBootstrap()
                // 选择分组方式，相当于第一层while循环
                .group(new NioEventLoopGroup())
                // 指定channel
                .channel(NioServerSocketChannel.class)
                // 指定worker的处理方法
                .childHandler(
                        new ChannelInitializer<NioSocketChannel>() {
                            @Override
                            protected void initChannel(NioSocketChannel ch) throws Exception {
                                ch.pipeline().addLast(new LoggingHandler());
                            }
                        }
                )
                // TODO dobind方法还没有解析完全，需要先解析NioEventLoopGroup的构造函数和类结构
                .bind(8080);
    }
}
